﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SuuntoWebsite.Events._201205
{
    public partial class Store : System.Web.UI.Page
    {
        protected static string sqlCon = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString_Event"].ConnectionString;
        protected string pkid = string.Empty;
        protected string userName = string.Empty;
        protected string userId = string.Empty;
        protected string rewrite = System.Configuration.ConfigurationManager.AppSettings["rewriteType"];
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Public.Cookie.UserId != "0")
            {
                userId = Public.Cookie.UserId;
                userName = Public.Cookie.UserName;
                if (GetCount())
                {
                    Public.Cookie.ProductId = pkid;
                }
                else
                {
                    Response.Redirect("./selection" + rewrite);
                }
            }
            else
            { Response.Redirect("./registration" + rewrite); }
        }
        protected bool GetCount()
        {
            pkid = Request["pd"];
            return new Bll.EventForSuunto.BLLSuunto_Products().SuuntoProductsCount(sqlCon, Convert.ToInt32(pkid));
        }
    }
}
